#include <stdio.h>

int main(void) {
  struct {
    char name[8];
    int age;
    int salary;
  } e[4];
  FILE *istream, *ostream;
  int i;

  istream = fopen("work.txt", "r");
  for (i = 0; i < 4; i++) {
    fscanf(istream, "%s%d%d", e[i].name, &e[i].age, &e[i].salary);
    printf("%s %d %d\n", e[i].name, e[i].age, e[i].salary);
    if (e[i].salary < 30000) {
      e[i].salary += 3000;
    }
  }
  fclose(istream);

  ostream = fopen("work.txt", "w");
  for (i = 0; i < 4; i++) {
    printf("%s %d %d\n", e[i].name, e[i].age, e[i].salary);
    fprintf(ostream, "%s %d %d\n", e[i].name, e[i].age, e[i].salary);
  }
  fclose(ostream);

  return 0;
}
